<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>专家库科室</title>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1">
    <!-- <link rel="shortcut icon" href="http://favicon.ico"> -->
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="viewport" content="width=device-width, height=device-height, user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0">

    <!--<link rel="stylesheet" href="//g.alicdn.com/msui/sm/0.6.2/css/sm-extend.min.css">-->

    <!-- 固定的css 和 common.js 的引用    -->
    <link rel="stylesheet" href="https://gitee.com/huaflower/CommonTraderUnionFile/raw/master/css/sm.min.css">
    <link rel="stylesheet" href="https://gitee.com/huaflower/CommonTraderUnionFile/raw/master/css/sm-extend.min.css">
    <script type="text/javascript" src="https://gitee.com/huaflower/CommonTraderUnionFile/raw/master/common/js/common.js"></script>
    
<style type="text/css">
   /*设置取消li、a标签默认样式*/
   *{
    margin:0;
    padding:0;
   }
   li{
    list-style: none;
   }
   a{
     text-decoration: none;
   }
  /*定义.page的样式*/
  .page{
    background:#fff;
  }
   /*头部样式*/
/*   .bar{background:#f7f7f8;padding:0 0.2rem 0 0;}*/
   /*定义#li_block的样式*/
   #li_block{
    width:100%;
    height:100%;
   }

  /*列表中ul,li的样式定义*/
  #li_block>ul{
    width:100%;
    height:100%;
    float:left;
  }
  #li_block>ul li{
  	width: 100;
  	line-height: 2.0rem;
    border-bottom:1px solid #ededee;
  }

</style>


</head>
<body>
<div class="page-group">
    <div class="page page-current">
           <!-- 标题栏 -->
<!-- 	      <header class="bar bar-nav" >
	           <a class="pull-left"><img src="https://gitee.com/huaflower/CommonTraderUnionFile/raw/master/img/back-a.png"></a>	      
	           <h1 class="title">专家库科室</h1>                         
	      </header> -->
	      <!-- 主题内容部分 -->
	      <div class="content infinite-scroll infinite-scroll-bottom" data-distance="100" onclick="bodyclick()">
	          <div class="list-block" id="li_block">
	              <ul class="list-container" >
	              </ul>
	          </div>
	          <!-- 加载提示符 -->
	          <div class="infinite-scroll-preloader">
	              <div class="preloader"></div>
	          </div>
	      </div>
    </div>
</div>



<!-- 固定的js引用，所有的jQuery 要用 $$ 表示 -->
<script type="text/javascript" src="https://gitee.com/huaflower/CommonTraderUnionFile/raw/master/js/jquery-1.11.1.min.js"></script>
<!-- 这一行代码是为了 避免js冲突 -->
<script type="text/javascript">var $$ =jQuery.noConflict();</script>
<script type='text/javascript' src='https://gitee.com/huaflower/CommonTraderUnionFile/raw/master/zepto/zepto.min.js' charset='utf-8'></script>
<script type='text/javascript' src='https://gitee.com/huaflower/CommonTraderUnionFile/raw/master/js/sm.min.js' charset='utf-8'></script>
<script type='text/javascript' src='https://gitee.com/huaflower/CommonTraderUnionFile/raw/master/js/sm-extend.min.js' charset='utf-8'></script>


<script type="text/javascript">
// 加载flag
      var loading = false;
      // 最多可加载的条目
      var maxItems = 100;
      var offset = 0
      var limit = 12
      var lastlength = 12;
      var datalist = new Array();;

      // 注册'infinite'事件处理函数
      $(document).on('infinite', '.infinite-scroll-bottom',function() {

          // 如果正在加载，则退出
          if (loading) return;

          // 设置flag
          loading = true;

          // 模拟1s的加载过程
          setTimeout(function() {
              // 重置加载flag
              loading = false;
              console.log('================'+lastlength + '====' + limit);


              if (lastlength < limit) {
                  // 加载完毕，则注销无限加载事件，以防不必要的加载
                  $.detachInfiniteScroll($('.infinite-scroll'));
                  // 删除加载提示符
                  $('.infinite-scroll-preloader').remove();
                  return;
              }
               offset = datalist.length;
               getData();
              // 添加新条目
              // addItems(itemsPerLoad, lastIndex);
              // 更新最后加载的序号
              //容器发生改变,如果是js滚动，需要刷新滚动
              $.refreshScroller();
          }, 1000);
      });
 			

  // 遍历数据 页面内容    
  function getData(){
    var param = {}
    //http://47.94.232.49
    var url = '/apis/books?offset='+offset+'&limit='+limit;

    net_request('get',url,param,successCallBack,errorCallBack);
  }

   //成功函数回调 页面
	function successCallBack(data){

	  // <li class="item-content" id="imli"><div class="item-inner" id="it_iner"><div class="item-title"><img  src="' + item.img + '"><span>' + item.name + '</span></div></div></li>
	  if (isNotNull(data)) {
	    var databody = data.data;
	    var html = '';
	    if (offset == 0) {
	      datalist = new Array();
	    }
	    if (isNotNull(databody)) {
	        
	       var html = '';
	       lastlength = databody.length;
	       for (var i = 0; i < databody.length; i++) {
	          var item = databody[i];
	          datalist.push(item);
	      }

	      for (var i = 0; i < datalist.length; i++) {
	            var item = datalist[i];
	            if (isNotNull(item)) {
	            html += '<li class="item-content" onclick="itemClick()"><div class="item-inner"><div class="item-title">' + item.name + '</div></div></li>';
	            }           
	      }
	    }
	             $('.infinite-scroll-bottom .list-container').html(html);
	  }
	}

	//失败函数回调
	function errorCallBack(data){
	  console.log(data);
	}
 
    function getParams(data){
	   // data需要转成json调用 ，函数urlParamParseJson();
	     /*var jodata = JSON.parse(data); 
	     if(isNotNull(jodata)){//
	        
	     }*/

	 }


   function itemClick(){
      native_goto("local/doctor/expert_person_list");
   }

   	// 初始化区域
  	$$(function () {
        getData();
      	$.init();
   	});

    
</script>
</body>
</html>